package com.bv.hr.system.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.bv.hr.system.entity.LoginLog;
import com.bv.hr.system.mapper.LoginLogMapper;
import com.bv.hr.system.service.LoginLogService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.Date;

/**
 * @author CYT7
 * @version 1.0
 * @time 12月 27,2021
 * @describe 服务接口实现
 */
@Slf4j
@RequiredArgsConstructor
@Service
public class LoginLogServiceImpl extends ServiceImpl<LoginLogMapper, LoginLog> implements LoginLogService {
    private final LoginLogMapper loginLogMapper;
    @Override
    @Transactional(rollbackFor = Exception.class)
    public int writeLoginLog(String userName, String ip) {
        LoginLog record = new LoginLog();
        record.setUserName(userName);
        record.setIp(ip);
        record.setCreateBy(userName);
        record.setCreateTime(new Date());
        loginLogMapper.insert(record);
        return 0;
    }
}
